#!/bin/bash

# Test md with single failure, multiple failure and all failure

. ./common

MD=true

for i in `seq 0 6`; do
	_start_sheep $i
done
_wait_for_sheep 7
_cluster_format -c 6
_vdi_create test 120M -P

# simulate one disk failure
_safe_remove $STORE/0/d0
_random | $DOG vdi write test
_wait_for_sheep_recovery 0
$DOG vdi check test
$DOG cluster info | _filter_cluster_info

# simulate multiple disk failure
_safe_remove $STORE/1/d0
_random | $DOG vdi write test &
sleep 1
_safe_remove $STORE/1/d1
_wait_for_sheep_recovery 0
wait
$DOG vdi check test
$DOG cluster info | _filter_cluster_info

# simulate all disks failure
_safe_remove $STORE/1/d2
_random | $DOG vdi write test
$DOG vdi check test
$DOG cluster info | _filter_cluster_info

# simulate simultaneous multiple disks failure
_safe_remove $STORE/2/d0
_safe_remove $STORE/2/d1
dd if=/dev/zero | $DOG vdi write test
$DOG vdi check test
$DOG cluster info | _filter_cluster_info
